package com.icss.daos;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.icss.beans.TravelVO;

public class TravelDao {
	Dao dao=null;
	
	public void insertTravel(String sql){
		dao=new Dao();
		boolean flag=dao.execute(sql);
		if(flag==true){
			System.out.println("出差申请成功");	
		}else{System.out.println("操作数据库失败-出差");}
		
	}
	//查询出差记录
	public List<TravelVO> selectTravel(String sql){
		List<TravelVO> list=new ArrayList<TravelVO>();
		dao=new Dao();
		ResultSet rs=dao.query(sql);
		try {
			while(rs.next()){
				TravelVO vo=new TravelVO();
				vo.setTravelId(rs.getInt("travelId"));
				vo.setTravelPersonName(rs.getString("travelName"));
				vo.setTravelPlace(rs.getString("travelPlace"));
				vo.setTravelReason(rs.getString("travelReason"));
				vo.setBeginTime(rs.getDate("beginTime"));
				vo.setEndTime(rs.getDate("endTime"));
				vo.setShenpiPerson(rs.getString("shenpiPerson"));
				vo.setTravelState(rs.getInt("State"));
				list.add(vo);
				System.out.println("出差记录不为空");
				
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}
	
	//更改出差状态
	public void editTravel(String sql){
		
		dao=new Dao();
		boolean flag=dao.execute(sql);
		if(flag==true){
			
			System.out.println("出差状态已改变");
		}else{System.out.println("出差状态改变失败");}
		
		
	}

}
